<template>
  <div class="router-link">
    <router-link to="/login">跳转到登录页</router-link>
    <router-link to="/home">跳转到首页</router-link>
    <router-link to="/newsUpDown">跳转到新闻上一篇下一篇</router-link>
  </div>
  <!-- 这是vue3的写法，与vue2的写法有所区别，如果这里使用vue2.x写法，会有警告 -->
  <router-view v-slot="{ Component }">
    <keep-alive>
      <component
        :is="Component"
        :key="$route.name"
        v-if="$route.meta.keepAlive"
      />
    </keep-alive>
    <component
      :is="Component"
      :key="$route.name"
      v-if="!$route.meta.keepAlive"
    />
  </router-view>
</template>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
.router-link {
  display: flex;
  flex-direction: column;
  width: 300px;
  flex-wrap: wrap;
  font-size: 25px;
  margin: 0 auto;
}
.router-link a {
  margin: 10px 0;
}
</style>
